package com.zzz.system.controller.user;

import com.zzz.common.core.controller.BaseController;
import com.zzz.common.core.domain.R;
import com.zzz.common.core.domain.TableDataInfo;
import com.zzz.system.domain.user.dto.UserDTO;
import com.zzz.system.domain.user.dto.UserQueryDTO;
import com.zzz.system.service.user.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: oj-project
 * @BelongsPackage: com.zzz.system.controller
 * @Author: zhai
 * @CreateTime: 2025-10-19  16:39
 * @Description: TODO 用户管理
 * @Version: 1.0
 */
@Slf4j
@Tag(name = "用户管理")
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {
    @Autowired
    private UserService userService;

    /**
     * @description: 获取c端用户列表
     * @author: zhai
     * @date: 2025/10/19 22:04
     * @param: [userQueryDTO]
     * @return: com.zzz.common.core.domain.TableDataInfo
     **/
    @GetMapping("/list")
    @Operation(summary = "获取c端用户列表", description = "获取c端用户列表")
    @ApiResponse(responseCode = "1000", description = "操作成功")
    @ApiResponse(responseCode = "2000", description = "操作失败")
    public TableDataInfo list(UserQueryDTO userQueryDTO) {
        log.info("查询用户列表，条件：{}，分页条件：{}，{}", userQueryDTO, userQueryDTO.getPageNum(), userQueryDTO.getPageSize());
        return getDataTable(userService.list(userQueryDTO));
    }
    /**
     * @description: 跟新用户的状态
     * @author: zhai
     * @date: 2025/10/23 07:54
     * @param: [userDTO]
     * @return: com.zzz.common.core.domain.R<java.lang.Void>
     **/
    @PutMapping("/updateStatus")
    @Operation(summary = "更新数据库中用户的状态信息", description = "更新数据库中用户的状态信息")
    @ApiResponse(responseCode = "1000", description = "操作成功")
    @ApiResponse(responseCode = "2000", description = "操作失败")
    public R<Void> updateStatus(@RequestBody UserDTO userDTO) {
        log.info("更新用户状态，用户ID：{}，状态：{}", userDTO.getUserId(), userDTO.getStatus());
        return toR(userService.updateStatus(userDTO));
    }
}
